import Vue from 'vue'
import Router from 'vue-router'

const Index = () => import(/* webpackChunkName: "index" */ '@/pages/index.vue')
const indexBookshelf = () => import(/* webpackChunkName: "indexBookshelf" */ '@/pages/index/bookshelf.vue')
const IndexStore = () => import(/* webpackChunkName: "indexStore" */ '@/pages/index/store.vue')
const indexMember = () => import(/* webpackChunkName: "indexMember" */ '@/pages/index/member.vue')
const IndexAccount = () => import(/* webpackChunkName: "indexAccount" */ '@/pages/index/account.vue')

const SearchResult = () => import(/* webpackChunkName: "searchResult" */ '@/pages/search-result.vue')
const Reader = () => import(/* webpackChunkName: "reader" */ '@/pages/reader.vue')
const Login = () => import(/* webpackChunkName: "login" */ '@/pages/login.vue')

Vue.use(Router)
// 需要左方向动画的路由用this.$router.to('****')
Router.prototype.togo = function (location, transition) {
  if (transition) {
    this.transition = transition
  } else {
    this.transition = 'van-fade'
  }
  this.push(location)
}

export default new Router({
  routes: [
    {
      path: '/',
      name: 'index',
      component: Index,
      redirect: '/bookshelf',
      children: [{
        path: '/bookshelf',
        name: 'bookshelf',
        component: indexBookshelf
      },
      {
        path: '/store',
        name: 'store',
        component: IndexStore
      },
      {
        path: '/member',
        name: 'member',
        component: indexMember
      },
      {
        path: '/account',
        name: 'account',
        component: IndexAccount
      }
      ]
    },
    {
      path: '/search/result',
      name: 'searchResult',
      component: SearchResult
    },
    {
      path: '/reader',
      name: 'reader',
      component: Reader
    },
    {
      path: '/login',
      name: 'login',
      component: Login
    }
  ]
})
